; RUN: opt < %s -load /home/user/Research/llvm-2.9-build-eclipse/lib/LLVMmpia.so \
; RUN:    -arraytracking -S -disable-output

; ModuleID = 'send_triangle.ll'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"

%struct.MPI_Status = type { i32, i32, i32, i32, i32 }
%struct.ompi_communicator_t = type opaque
%struct.ompi_datatype_t = type opaque
%struct.ompi_predefined_communicator_t = type opaque
%struct.ompi_predefined_datatype_t = type opaque

@ompi_mpi_comm_world = external global %struct.ompi_predefined_communicator_t
@ompi_mpi_float = external global %struct.ompi_predefined_datatype_t
@.str = private constant [7 x i8] c"%4.1f \00", align 1

define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
  %argc_addr = alloca i32, align 4
  %argv_addr = alloca i8**, align 4
  %p = alloca i32
  %my_rank = alloca i32
  %A = alloca [10 x [10 x float]]
  %T = alloca [10 x [10 x float]]
  %displacements = alloca [10 x i32]
  %block_lengths = alloca [10 x i32]
  %index_mpi_t = alloca %struct.ompi_datatype_t*
  %status = alloca %struct.MPI_Status
  %"alloca point" = bitcast i32 0 to i32
  store i32 %argc, i32* %argc_addr
  store i8** %argv, i8*** %argv_addr
  %0 = call i32 @MPI_Init(i32* %argc_addr, i8*** %argv_addr) nounwind
  %1 = call i32 @MPI_Comm_size(%struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), i32* %p) nounwind
  %2 = call i32 @MPI_Comm_rank(%struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), i32* %my_rank) nounwind
  br label %bb1

bb:                                               ; preds = %bb1
  %3 = sub nsw i32 10, %i.0
  %4 = getelementptr inbounds [10 x i32]* %block_lengths, i32 0, i32 %i.0
  store i32 %3, i32* %4, align 4
  %5 = mul nsw i32 %i.0, 11
  %6 = getelementptr inbounds [10 x i32]* %displacements, i32 0, i32 %i.0
  store i32 %5, i32* %6, align 4
  %7 = add nsw i32 %i.0, 1
  br label %bb1

bb1:                                              ; preds = %bb, %entry
  %i.0 = phi i32 [ 0, %entry ], [ %7, %bb ]
  %8 = icmp sle i32 %i.0, 9
  br i1 %8, label %bb, label %bb2

bb2:                                              ; preds = %bb1
  %block_lengths3 = bitcast [10 x i32]* %block_lengths to i32*
  %displacements4 = bitcast [10 x i32]* %displacements to i32*
  %9 = call i32 @MPI_Type_indexed(i32 10, i32* %block_lengths3, i32* %displacements4, %struct.ompi_datatype_t* bitcast (%struct.ompi_predefined_datatype_t* @ompi_mpi_float to %struct.ompi_datatype_t*), %struct.ompi_datatype_t** %index_mpi_t) nounwind
  %10 = call i32 @MPI_Type_commit(%struct.ompi_datatype_t** %index_mpi_t) nounwind
  %11 = load i32* %my_rank, align 4
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %bb5, label %bb14

bb5:                                              ; preds = %bb2
  br label %bb10

bb6:                                              ; preds = %bb10
  br label %bb8

bb7:                                              ; preds = %bb8
  %13 = sitofp i32 %i.1 to float
  %14 = sitofp i32 %j.0 to float
  %15 = fadd float %13, %14
  %16 = getelementptr inbounds [10 x [10 x float]]* %A, i32 0, i32 %i.1
  %17 = getelementptr inbounds [10 x float]* %16, i32 0, i32 %j.0
  store float %15, float* %17, align 4
  %18 = add nsw i32 %j.0, 1
  br label %bb8

bb8:                                              ; preds = %bb7, %bb6
  %j.0 = phi i32 [ 0, %bb6 ], [ %18, %bb7 ]
  %19 = icmp sle i32 %j.0, 9
  br i1 %19, label %bb7, label %bb9

bb9:                                              ; preds = %bb8
  %20 = add nsw i32 %i.1, 1
  br label %bb10

bb10:                                             ; preds = %bb9, %bb5
  %i.1 = phi i32 [ 0, %bb5 ], [ %20, %bb9 ]
  %21 = icmp sle i32 %i.1, 9
  br i1 %21, label %bb6, label %bb11

bb11:                                             ; preds = %bb10
  %22 = load %struct.ompi_datatype_t** %index_mpi_t, align 4
  %A12 = bitcast [10 x [10 x float]]* %A to [10 x float]*
  %A1213 = bitcast [10 x float]* %A12 to i8*
  %23 = call i32 @MPI_Send(i8* %A1213, i32 1, %struct.ompi_datatype_t* %22, i32 1, i32 0, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*)) nounwind
  br label %bb28

bb14:                                             ; preds = %bb2
  br label %bb19

bb15:                                             ; preds = %bb19
  br label %bb17

bb16:                                             ; preds = %bb17
  %24 = getelementptr inbounds [10 x [10 x float]]* %T, i32 0, i32 %i.2
  %25 = getelementptr inbounds [10 x float]* %24, i32 0, i32 %j.1
  store float 0.000000e+00, float* %25, align 4
  %26 = add nsw i32 %j.1, 1
  br label %bb17

bb17:                                             ; preds = %bb16, %bb15
  %j.1 = phi i32 [ 0, %bb15 ], [ %26, %bb16 ]
  %27 = icmp sle i32 %j.1, 9
  br i1 %27, label %bb16, label %bb18

bb18:                                             ; preds = %bb17
  %28 = add nsw i32 %i.2, 1
  br label %bb19

bb19:                                             ; preds = %bb18, %bb14
  %i.2 = phi i32 [ 0, %bb14 ], [ %28, %bb18 ]
  %29 = icmp sle i32 %i.2, 9
  br i1 %29, label %bb15, label %bb20

bb20:                                             ; preds = %bb19
  %30 = load %struct.ompi_datatype_t** %index_mpi_t, align 4
  %T21 = bitcast [10 x [10 x float]]* %T to [10 x float]*
  %T2122 = bitcast [10 x float]* %T21 to i8*
  %31 = call i32 @MPI_Recv(i8* %T2122, i32 1, %struct.ompi_datatype_t* %30, i32 0, i32 0, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), %struct.MPI_Status* %status) nounwind
  br label %bb27

bb23:                                             ; preds = %bb27
  br label %bb25

bb24:                                             ; preds = %bb25
  %32 = getelementptr inbounds [10 x [10 x float]]* %T, i32 0, i32 %i.3
  %33 = getelementptr inbounds [10 x float]* %32, i32 0, i32 %j.2
  %34 = load float* %33, align 4
  %35 = fpext float %34 to double
  %36 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), double %35) nounwind
  %37 = add nsw i32 %j.2, 1
  br label %bb25

bb25:                                             ; preds = %bb24, %bb23
  %j.2 = phi i32 [ 0, %bb23 ], [ %37, %bb24 ]
  %38 = icmp sle i32 %j.2, 9
  br i1 %38, label %bb24, label %bb26

bb26:                                             ; preds = %bb25
  %39 = call i32 @putchar(i32 10) nounwind
  %40 = add nsw i32 %i.3, 1
  br label %bb27

bb27:                                             ; preds = %bb26, %bb20
  %i.3 = phi i32 [ 0, %bb20 ], [ %40, %bb26 ]
  %41 = icmp sle i32 %i.3, 9
  br i1 %41, label %bb23, label %bb28

bb28:                                             ; preds = %bb27, %bb11
  %42 = call i32 @MPI_Finalize() nounwind
  br label %return

return:                                           ; preds = %bb28
  ret i32 undef
}

declare i32 @MPI_Init(i32*, i8***)

declare i32 @MPI_Comm_size(%struct.ompi_communicator_t*, i32*)

declare i32 @MPI_Comm_rank(%struct.ompi_communicator_t*, i32*)

declare i32 @MPI_Type_indexed(i32, i32*, i32*, %struct.ompi_datatype_t*, %struct.ompi_datatype_t**)

declare i32 @MPI_Type_commit(%struct.ompi_datatype_t**)

declare i32 @MPI_Send(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*)

declare i32 @MPI_Recv(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*, %struct.MPI_Status*)

declare i32 @printf(i8* noalias, ...) nounwind

declare i32 @putchar(i32)

declare i32 @MPI_Finalize()
